<template>
  <div class="news-container">
    <van-cell-group
      v-for="item in userList"
      :key="item._id"
    >
      <van-cell
        class="base-info"
        center
        :border='false'
      >
        <div class="name" slot="title">请假人：{{ item.name }}</div>
        <div class="name" slot="title">审核情况：{{ item.examine }}</div>
        <van-button
          class="update-btn"
          size="small"
          round
          @click="$router.push(`/leave/leaveInfo?id=${item._id}`)"
        >查看详情</van-button>
      </van-cell>
    </van-cell-group>
  </div>
</template>

<script>
import { getLeave } from '@/api/leave'
export default {
  name: 'NewsIndex',
  components: {},
  props: {},
  data () {
    return {
      // userList: []
      userList: this.getLeaveInfo()
    }
  },
  computed: {},
  watch: {},
  created () {
    // this.getLeaveInfo()
  },
  mounted () {},
  methods: {
    getLeaveInfo () {
      if (this.$store.state.user.role === 'admin') {
        getLeave().then(res => {
          console.log(res)
          this.userList = res.data.data
        })
      } else {
        getLeave({
          mobile: this.$store.state.user.mobile
        }).then(res => {
          console.log(res)
          this.userList = res.data.data
        })
      }
    }
  }
}
</script>

<style scoped lang="">

</style>
